<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="//cdn.bootcss.com/jquery/1.9.0/jquery.js"></script>
    <script>
        var wsServer = 'ws://127.0.0.1:9527';
        var websocket = new WebSocket(wsServer);
        websocket.onopen = function (evt) {
            websocket.send('<?=json_encode($sign)?>');
        };

        websocket.onclose = function (evt) {
            console.log('close');
        };

        websocket.onmessage = function (evt) {
            var json = $.parseJSON(evt.data);

            // 转交函数处理相关事件
            if (json.type) {
                var fuc = eval(json.type);
                fuc.apply(this,json.args);
            }

            console.log(json);
        };
        websocket.onerror = function (evt, e) {
            console.log(evt);
            console.log(e);
        };

        /**
         * 新增订单处理函数
         * @param order_id
         */
        function newRechargeOrder( order_id,msg ){
            console.log(order_id);
        }

    </script>
</head>
<body>
<audio style="display:none;" id="bgMusic" src="http://xunlei.sc.chinaz.com/files/download/sound1/201411/5103.wav"></audio>
</body>
</html>
